package com.tourscool.springboot.starter;

import com.tourscool.springboot.starter.redisson.RedisExecBuilder;
import org.redisson.api.RLock;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class RedissionApplication {

    public static void main(String[] args) throws Throwable {
        SpringApplication.run(RedissionApplication.class, args);

        RedisExecBuilder.build().execThrows(redissonClient -> {
            RLock rLock = redissonClient.getLock("test_lock");
            try {
                System.out.println(rLock.tryLock());
            } catch (Exception ignore) {

            } finally {
                try {
                    if (rLock != null && rLock.isLocked()) {
                        rLock.unlock();
                    }
                } catch (Throwable e) {
                    e.printStackTrace();
                }

            }

            return true;
        });
    }

}
